
Page({
    data: {
        active:0,
        result:[],
        times:[]
    },
    onShow(){
        let that = this
        let token = wx.getStorageSync("token")
        wx.request({
            url: "https://www.cbing.icu:8095/wxUser/getAllOrder",
            method: 'GET',
            header: {
                'Authorization': token
            },
            success(res) {
                let result = res.data.data
                console.log(result)
                that.setData({
                    result:result
                })
                let times = []
                let priceAll = []
               for (let i of result){
                   let priceNow = 0
                   let date = new Date(i.time)
                   let Y = date.getFullYear() + '-';
                   let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                   let D = date.getDate() + ' ';
                   let h = date.getHours() + ':';
                   let m = date.getMinutes() + ':';
                   let s = date.getSeconds();
                   times.push(Y+M+D+h+m+s)
                   for (let item of i.goodsShopcarts){
                       priceNow+=item.goods.price*item.num
                   }
                   priceAll.push((priceNow-1).toFixed(2))
               }
               that.setData({
                   times:times,
                   priceAll:priceAll
               })
            }
        })
    },
    onChange(event) {

    }
})